home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ARM / SPINLOCK.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  78 lines

  1. #ifndef __ASM_SPINLOCK_H
  2. #define __ASM_SPINLOCK_H
  3.  
  4. #ifndef __SMP__
  5.  
  6. /*
  7.  * To be safe, we assume the only compiler that can cope with
  8.  * empty initialisers is EGCS.
  9.  */
  10. #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 90))
  11. #define EMPTY_INIT_OK
  12. #endif
  13.  
  14. /*
  15.  * Your basic spinlocks, allowing only a single CPU anywhere
  16.  */
  17. #ifdef EMPTY_INIT_OK
  18.   typedef struct { } spinlock_t;
  19. # define SPIN_LOCK_UNLOCKED (spinlock_t) { }
  20. #else
  21.   typedef unsigned char spinlock_t;
  22. # define SPIN_LOCK_UNLOCKED 0
  23. #endif
  24.  
  25. #define spin_lock_init(lock)    do { } while(0)
  26. #define spin_lock(lock)        do { } while(0)
  27. #define spin_trylock(lock)    do { } while(0)
  28. #define spin_unlock_wait(lock)    do { } while(0)
  29. #define spin_unlock(lock)    do { } while(0)
  30. #define spin_lock_irq(lock)    cli()
  31. #define spin_unlock_irq(lock)    sti()
  32.  
  33. #define spin_lock_irqsave(lock, flags) \
  34.     do { __save_flags_cli(flags); } while (0)
  35. #define spin_unlock_irqrestore(lock, flags) \
  36.     restore_flags(flags)
  37.  
  38. /*
  39.  * Read-write spinlocks, allowing multiple readers
  40.  * but only one writer.
  41.  *
  42.  * NOTE! it is quite common to have readers in interrupts
  43.  * but no interrupt writers. For those circumstances we
  44.  * can "mix" irq-safe locks - any writer needs to get a
  45.  * irq-safe write-lock, but readers can get non-irqsafe
  46.  * read-locks.
  47.  */
  48. #ifdef EMPTY_INIT_OK
  49.   typedef struct { } rwlock_t;
  50. # define RW_LOCK_UNLOCKED (rwlock_t) { }
  51. #else
  52.   typedef unsigned char rwlock_t;
  53. # define RW_LOCK_UNLOCKED 0
  54. #endif
  55.  
  56. #define read_lock(lock)        do { } while(0)
  57. #define read_unlock(lock)    do { } while(0)
  58. #define write_lock(lock)    do { } while(0)
  59. #define write_unlock(lock)    do { } while(0)
  60. #define read_lock_irq(lock)    cli()
  61. #define read_unlock_irq(lock)    sti()
  62. #define write_lock_irq(lock)    cli()
  63. #define write_unlock_irq(lock)    sti()
  64.  
  65. #define read_lock_irqsave(lock, flags)    \
  66.     do { __save_flags_cli(flags); } while (0)
  67. #define read_unlock_irqrestore(lock, flags) \
  68.     restore_flags(flags)
  69. #define write_lock_irqsave(lock, flags)    \
  70.     do { __save_flags_cli(flags); } while (0)
  71. #define write_unlock_irqrestore(lock, flags) \
  72.     restore_flags(flags)
  73.  
  74. #else
  75. #error ARM architecture does not support spin locks
  76. #endif /* SMP */
  77. #endif /* __ASM_SPINLOCK_H */
  78.